import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

const router = new Router({
  routes: [
    // {
    //   path: '*',
    //   redirect: '/'
    // },
    // {
    //   path: '/',
    //   name: 'test',
    //   component: resolve => require(['@/view/testvuex'], resolve),
    //   meta: {
    //     title: '测试'
    //   },
    //   // redirect:'/login'
    // },
    {
      path: '/',
      name: 'login',
      component: resolve => require(['@/view/Login'], resolve),
      meta: {
        title: '登录'
      },
      // redirect:'/login'
    },
    {
      path: '/register',
      name: 'register',
      component: resolve => require(['@/view/Register'], resolve),
      meta: {
        title: '注册'
      },
    },
    {
      path: '/usersup',
      name: 'usersup',
      component: resolve => require(['@/view/usersUp'], resolve),
      meta: {
        title: '企业认证'
      },
    },

    {
      path: '/PageView',
      // path: '/',
      name: 'PageView',
      component: resolve => require(['@/view/PageView'], resolve),
      redirect: '/home',
      children: [
        {
          path: '/home',
          // path: '/',
          name: 'home',
          component: resolve => require(['@/view/HomePage'], resolve),
          meta: {
            title: '首页'
          }
        },
        {
          path: '/LPL',
          name: 'LPL',
          component: resolve => require(['@/view/LPL'], resolve),
          meta: {
            title: '小拼箱'
          },
          // children: [
          //   {
          //     path: '/software',
          //     redirect: '/software/smartTown'
          //   },
          //   {
          //     path: '/software/smartTown',
          //     name: 'software',
          //     component: resolve => require(['@/view/Software_smartTown'], resolve),
          //     meta: {
          //       title: '软件产品丨智能小镇管理系统'
          //     }
          //   },
          //   {
          //     path: '/software/bigData',
          //     name: 'software',
          //     component: resolve => require(['@/view/Software_bigData'], resolve),
          //     meta: {
          //       title: '软件产品丨大数据管理系统'
          //     }
          //   }
          // ]
        },
        {
          path: '/service',
          name: 'service',
          component: resolve => require(['@/view/Service'], resolve),
          meta: {
            title: '主要产品'
          }
        },
        {
          path: '/newsinformation',
          name: 'newsinformation',
          component: resolve => require(['@/view/NewsInformation'], resolve),
          meta: {
            title: '新闻动态'
          }
        },
        {
          path: '/companyintroduction',
          name: 'companyintroduction',
          component: resolve => require(['@/view/CompanyIntroduction'], resolve),
          meta: {
            title: '公司介绍'
          }
        },
        {
          path: '/jobchance',
          name: 'jobchance',
          component: resolve => require(['@/view/JobChance'], resolve),
          meta: {
            title: '工作机会'
          },
          // children: [
          //   // {
          //   //   path: '/software',
          //   //   redirect: '/software/smartTown'
          //   // },
          //   // {
          //   //   path: '/software/smartTown',
          //   //   name: 'software',
          //   //   component: resolve => require(['@/view/Software_smartTown'], resolve),
          //   //   meta: {
          //   //     title: '软件产品丨智能小镇管理系统'
          //   //   }
          //   // },
          //   {
          //     path: '/map',
          //     name: 'map',
          //     component: resolve => require(['@/view/Map'], resolve),
          //     meta: {
          //       title: '物流可视化'
          //     }  
          //   },
          //   {
          //     path: '/myorder',
          //     name: 'myorder',
          //     component: resolve => require(['@/view/Myorder'], resolve),
          //     meta: {
          //       title: '我的订单'
          //     }  
          //   }
          // ]

        },
        {
          path: '/contactus',
          name: 'contactus',
          component: resolve => require(['@/view/ContactUs'], resolve),
          meta: {
            title: '联系我们'
          }
        },
        {
          path: '/servicedetail',
          name: 'servicedetail',
          component: resolve => require(['@/view/ServiceDetail'], resolve),
          meta: {
            title: '相关服务'
          }
        },
        {
          path: '/ProductDetail',
          name: 'ProductDetail',
          component: resolve => require(['@/view/ProductDetail'], resolve),
          meta: {
            title: '舱位详情'
          }
        },
        // 我的工作台
        {
          path: '/map',
          name: 'map',
          component: resolve => require(['@/view/myjob/Map'], resolve),
          meta: {
            title: '物流可视化'
          }
        },
        {
          path: '/myorder',
          name: 'myorder',
          component: resolve => require(['@/view/myjob/Myorder'], resolve),
          meta: {
            title: '我的订单'
          }
        },
        {
          path: '/clientorder',
          name: 'clientorder',
          component: resolve => require(['@/view/myjob/clientOrder'], resolve),
          meta: {
            title: '客户订单'
          }
        },
        {
          path: '/mysend',
          name: 'mysend',
          component: resolve => require(['@/view/myjob/Mysend'], resolve),
          meta: {
            title: '我的发布'
          }
        },
        {
          path: '/sendproduct',
          name: 'sendproduct',
          component: resolve => require(['@/view/myjob/Sendproduct'], resolve),
          meta: {
            title: '发布舱位'
          }
        },
        // 个人中心
        {
          path: '/userinfo',
          name: 'userinfo',
          component: resolve => require(['@/view/Userinfo'], resolve),
          meta: {
            title: '个人中心'
          },
          children: [
            {
              path: '/myinfo',
              name: 'myinfo',
              component: resolve => require(['@/view/userinfo/myinfo'], resolve),
            },
            {
              path: '/myaddress',
              name: 'myaddress',
              component: resolve => require(['@/view/userinfo/myAddress'], resolve),

            },
            {
              path: '/addinfo',
              name: 'addinfo',
              component: resolve => require(['@/view/userinfo/addinfo'], resolve),
            },
            {
              path: '/addaddress',
              name: 'addaddress',
              component: resolve => require(['@/view/userinfo/addAddress'], resolve),

            },
            {
              path: '/mylike',
              name: 'mylike',
              component: resolve => require(['@/view/userinfo/mylike'], resolve),
            },

          ]
        },
        {
          path: '/newsdetail',
          name: 'newsdetail',
          component: resolve => require(['@/view/NewsDetail'], resolve),
        }
      ]
    }
  ]
})

// 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//     if (to.path === '/login') return next()
//     // 获取token和角色
// //     const tokenStr = window.sessionStorage.getItem('token')
// //     const role = window.sessionStorage.getItem('role')
// //     console.log('tokenStr--',tokenStr)
// //     if (!tokenStr) return next('/login')
//     if (role === 'normal' && (to.path === '/' || to.path.substr(0, 7) === '/admin/')) {
//         return next('/login')
//     }
//     //(to.path === '/' || to.path === '/home' || to.path === '/welcome' || to.path === '/user' || to.path === '/category' || to.path === '/single' || to.path === '/combo')
//     next()
// })

export default router
